package za.ac.wits.elen7045.persistence.model;

import java.util.LinkedList;
import java.util.List;

public enum ServiceProviderName {

	TESTING					(AccountType.OTHER, 				 "TEST"),
	VODACOM					(AccountType.TELCO_SERVICE_PROVIDER, "VODACOM"),
	MTN						(AccountType.TELCO_SERVICE_PROVIDER, "MTN"),
	CITY_OF_JOBURG			(AccountType.MUNICIPALITY, 			 "CITY_OF_JOBURG"),
	DISCOVERY_CREDIT_CARD	(AccountType.CREDIT_CARD_PROVIDER,	 "DISCOVERY"),
	PAY_FINE				(AccountType.OTHER,					 "PAY_FINE");
	
	public static List<ServiceProviderName> getServiceProviderTypeByAccountType(AccountType accountType) {
		List<ServiceProviderName> serviceProviderTypes = new LinkedList<ServiceProviderName>();
		for (ServiceProviderName providerType : values()) {
			if (providerType.getAccountType() == accountType) {
				serviceProviderTypes.add(providerType);
			}
		}
		return serviceProviderTypes;
	}
	
	public static ServiceProviderName getServiceProviderTypeByName(String name) {
		for (ServiceProviderName providerType : values()) {
			if (providerType.getName().equals(name)) {
				return providerType;
			}
		}
		return null;
	}
	
	private ServiceProviderName(AccountType accountType, String name) {
		this.accountType = accountType;
		this.name = name;
	}
	
	public AccountType getAccountType() {
		return accountType;
	}
	
	public String getName() {
		return name;
	}
	
	private AccountType accountType;
	private String name;
	
}
